﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Classes
{
    class Searcher
    {
        IList<City> airports;
        IList<City> visited;
        IGraphImpl graph;
        //here I have some fields to work on our own data, of course we will get it rom 
        City aalborg;
        City copenhagen;
        City aarhus;
        City berlin;
        City budapest;
        City sofia;
        City warsaw;
        City vilnus;
        City madrid;
        City moscow;
        City tbilisi;
        City astana;
        public Searcher()
        {
            airports = new List<City>();
            aalborg = new City("Aalborg", "Denmark");
            copenhagen = new City("Copenhagen", "Denmark");
            aarhus = new City("Aarhus", "Demnark");
            berlin = new City("Berlin", "Germany");
            budapest = new City("Budapest", "Romania");
            sofia = new City("Sofia", "Bulagria");
            warsaw = new City("Warsaw", "Poland");
            vilnus = new City("Vilnus", "Lithuania");
            madrid = new City("Madrid", "Spain");
            moscow = new City("Moscow", "Russia");
            tbilisi = new City("Tblisi", "Georgia");
            astana = new City("Astana", "Kazakhstan");

            visited = new List<City>();

            graph = new GraphImpl();


            graph.AddCity(aalborg);
            graph.AddCity(copenhagen);
            graph.AddCity(aarhus);
            graph.AddCity(berlin);
            graph.AddCity(budapest);
            graph.AddCity(sofia);
            graph.AddCity(warsaw);
            graph.AddCity(vilnus);
            graph.AddCity(madrid);
            graph.AddCity(moscow);
            graph.AddCity(tbilisi);
            graph.AddCity(astana);
            graph.AddFlight(aalborg, copenhagen, 5);
            graph.AddFlight(aalborg, aarhus, 1);
            graph.AddFlight(aarhus, copenhagen, 2);
            graph.AddFlight(copenhagen, aalborg, 4);
            graph.AddFlight(copenhagen, aarhus, 13);
            graph.AddFlight(copenhagen, berlin, 7);
            graph.AddFlight(aalborg, berlin, 6);
            graph.AddFlight(berlin, moscow, 12);
            graph.AddFlight(moscow, tbilisi, 4);
            graph.AddFlight(tbilisi, astana, 5);
            graph.AddFlight(berlin, copenhagen, 4);
            graph.AddFlight(berlin, budapest, 7);
            graph.AddFlight(berlin, warsaw, 3);
            graph.AddFlight(warsaw, berlin, 9);
            graph.AddFlight(budapest, berlin, 10);
            graph.AddFlight(sofia, budapest, 4);
            graph.AddFlight(berlin, sofia, 5);
            graph.AddFlight(warsaw, vilnus, 3);
            graph.AddFlight(vilnus, warsaw, 11);
            graph.AddFlight(vilnus, berlin, 4);
            graph.AddFlight(berlin, astana, 5);
            graph.AddFlight(madrid, berlin, 6);
            graph.AddFlight(berlin, madrid, 3);
            graph.AddFlight(madrid, sofia, 6);
            graph.AddFlight(budapest, sofia, 9);
            graph.AddFlight(astana, budapest, 7);
            graph.AddFlight(berlin, aalborg, 2);
            graph.AddFlight(warsaw, madrid, 4);
       //     graph.AddFlight(aarhus, berlin, 1);



        }
        public IGraphImpl ReturnGraph()
        {
            return graph;
        }
        public void MakeASearchInGraph()
        {
            graph.Dijkstra(aalborg);
            //graph.PrintPath(aalborg);
            //foreach (City c in graph.GetCities())
            //{
            //    Console.WriteLine(c.Name);
            //    Console.WriteLine(c.Distance);

            //    if (c.Path != null)
            //    {
            //        foreach (City f in c.Path)
            //        {
            //            Console.WriteLine(f.Name);
            //        }
            //    }
            //    Console.ReadLine();

            //    }
            //    Console.ReadLine();

            //}
        }

            // graph.PrintPath(aalborg);






            //     foreach (City c in graph.ReturnCityList())
            //{
            //foreach(City f in graph.GetAdjacencies(c))
            //{
            //    Console.WriteLine(f.Name);
            //}


            //foreach(City c in v.CitiesList())
            //{
            //    Console.WriteLine(c.Name);
            //}




        }
    }



          //ListOfConnections listOfConnections = new ListOfConnections();
          //  listOfConnections = graph.SearchForConnections(aalborg, sofia);
          //  foreach (Connection a in listOfConnections.GetConnectionList())
          //  {
          //      Console.WriteLine("******");
          //      foreach (Flight g in a.FlightList())
          //      {
          //          Console.WriteLine(g.From.Name + " ---> " + g.To.Name);
          //      }
          //  }
          //  graph.setToNullListOfConnections();
          //  ListOfConnections listOfConnections2 = new ListOfConnections();
          //  listOfConnections2 = graph.SearchForConnections(aalborg, copenhagen);
          //  foreach (Connection a in listOfConnections2.GetConnectionList())
          //  {
          //      Console.WriteLine("******");
          //      foreach (Flight g in a.FlightList())
          //      {
          //          Console.WriteLine(g.From.Name + " ---> " + g.To.Name);
          //      }
          //  }
          //  Console.ReadLine();
          //  }